% fields H for rho > a & rho < a

function [rho, phi, z] = func_H_outside_check(r, m, CONSTS, coef, p1)

    k0    = CONSTS.k0;
    a     = CONSTS.a;
        
    if (isnan(p1))
        rho = 0;
        phi = 0;
        z   = 0;
        return;
    end
    
    C1 = coef(3);
    C2 = coef(4);

    s      = func_s(p1, CONSTS);

    S = k0*a*s;
    if(m>=0)
        besselK_m = besselk(m, S*r);
        besselK_mp1 = besselk(m+1, S*r);
    else
        m1=abs(m);
        besselK_m = besselk(m1, S.*r);
        besselK_mp1 = besselk(m1+1, S.*r)-((2*m1./S).*besselk(m1, S.*r));
    end
    
    rho = 1i*(C1*(m./(S*r)).*besselK_m - ...
                        C2*p1*(besselK_mp1 - (m./(S*r)).*besselK_m));
    
    phi = -C1*(besselK_mp1 - (m./(S*r)).*besselK_m) + ...
                     C2*p1*(m./(S*r)).*besselK_m;
    
    z   = C2*s*besselK_m;
    
end
